<!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
  <meta http-equiv="Content-Type"
 content="text/html; charset=iso-8859-1">
  <meta name="GENERATOR"
 content="Mozilla/4.76 [en] (Windows NT 5.0; U) [Netscape]">
  <meta name="Template"
 content="C:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE\html.dot">
  <title>WinPMC</title>
</head>
<body text="#000000" bgcolor="#ffffff" link="#0000ff" vlink="#800080"
 leftmargin="8">
<h1>
<a name="WINPMC"></a><font face="Verdana">WinPMC</font></h1>
<h3><small><small>
<font face="Verdana">SUMMARY</font></small></small></h3>
<font face="Verdana"><font size="-1">This device driver enables and
controls
access to the Performance Monitor Counters and the RDPMC assembly
instruction
on Pentium MMX class processors from a user application.</font></font>
<p><font face="Verdana"><font size="-1">The driver building and
installation
instructions given here only apply to Windows&reg; 2000.</font></font>
<br>
</p>
<h2><font face="Verdana"><font size="-1">BUILDING THE DRIVER</font></font></h2>
<font face="Verdana"><font size="-1"><b>Note</b>: To build this driver,
it
is assumed that you have already installed a current version of the
Windows
DDK toolkit. In the past, the toolkit was available at <a
 href="http://www.microsoft.com/ddk/">http://www.microsoft.com/ddk/</a>.
Now it can be requested from that website, or found on someone's
subscription to MSDN. There are two ways to build the WinPMC driver.
The first uses the command line. It is the simplest and quickest. The
second requires more setup, but is well integrated with the Microsoft
Visual Studio development environment.<br>
</font></font>
<h3><font face="Verdana"><font size="-1">BUILDING WITH THE COMMAND LINE<br>
</font></font></h3>
<font face="Verdana"><font size="-1">Click the Free Build
Environment
or Checked Build Environment icon under your <b>Developement Kits </b>program
group to set basic environment variables needed by the build utility.</font></font>
<p></p>
<p><font face="Verdana"><font size="-1">Change to the directory
containing
the device source code. By default this is:</font></font>
<br>
<font face="Verdana"><font size="-1">&nbsp;&nbsp;&nbsp; <b>&gt;CD
C:\papi\src\win2k\winpmc</b>.</font></font>
</p>
<h4><font face="Verdana"><font size="-1">The First Time</font></font></h4>
<font face="Verdana"><font size="-1">Run <b>build -ceZ</b>, or use the
macro
<b>BLD</b>.
This behavior invokes the Microsoft make routines that produce log
files
called Buildxxx.log, and also Buildxxx.wrn and Buildxxx.err if there
are
any warnings or errors. Where xxx stands for <b>fre</b> or
<b>chk</b> depending
on the environment chosen. If the build succeeds, the driver WinPMC.sys
will be placed in a platform specific subdirectory of your
<b>%TargetPath%</b>
directory specified in the Sources file. By default, this will be:</font></font>
<br>
<font face="Verdana"><font size="-1">&nbsp;&nbsp; <b>&gt;CD
C:\papi\src\win2k\winpmc\sys\[objchk
objfre]\i386\</b>.</font></font>
<h4><font face="Verdana"><font size="-1">Driver Installation</font></font></h4>
<font face="Verdana"><font size="-1">To install the driver, run the
batch
file <b>instpmc.bat </b>found in the<b> winpmc </b>directory. This
batch
file copies the driver to <b>C:\WINNT\system32\drivers</b>, invokes
the
included <b>ntaddsvc</b> application to modify the registry, and
invokes
<b>net
start</b> to load the driver.</font></font>
<br>
<font face="Verdana"><font size="-1"><b>Note</b>: It may be necessary
to edit the batch file if your directory structure does not match the
default.</font></font>
<h4><font face="Verdana"><font size="-1">Successive Builds</font></font></h4>
<font face="Verdana"><font size="-1">After the first build and
installation,
use&nbsp; <b>bldpmc.bat</b> within the Checked or Free Build
Environment.
This batch file unloads the current driver; builds a new one; copies it
to the drivers directory; and reloads the driver for execution and
testing.</font></font>
<p><font face="Verdana"><font size="-1"><b>Note</b>: It may be
necessary
to edit the batch files if your directory structure does not match the
default.<br>
</font></font></p>
<h3><font face="Verdana"><font size="-1">MICROSOFT VISUAL STUDIO</font></font></h3>
<p style="font-family: verdana;"><small>If you are using M<small>icrosoft
Visual Studio, you may find the above
process to be clumsy and counter-intuitive. A batch file, ddkbuild.bat,
is available from HollisTech that simplifies this process and
integrates it into the Visual Studio environment. This batch file and
supporting documentation is available here:&nbsp; </small><a
 href="http://www.hollistech.com/Resources/ddkbuild/ddkbuild.htm">http://www.hollistech.com/Resources/ddkbuild/ddkbuild.htm</a>.
</small></p>
<p style="font-family: verdana;"><small>The batch file itself must be
installed somewhere that Visual Studio can find it. On my computer it's
in <span style="font-weight: bold;">C:\Program Files\Microsoft Visual
Studio .NET 2003\Common7\Tools</span>. </small></p>
<p style="font-family: verdana;"><small>In addition, an environment
variable must be defined as specified in the HollisTech documentation.
This variable must point to your installation of the DDK. For
simplicity, the variable I use is <span style="font-weight: bold;">WKBASE
== C:\WINDDK\3790</span>. To define this variable, go to <span
 style="font-weight: bold;">Start-&gt;Setting-&gt;Control
Panel-&gt;System-&gt;Advanced-&gt;Environment Variables</span> and
define a new system variable with a definition appropriate for your
installation.</small></p>
<p style="font-family: verdana;"><small>The third piece of the puzzle
is the modification of the project itself. This has already been done
for the WinPMC project inside the WinPAPI Shell Solution. It is also
described in detail in the HollisTech documentation. As a quick review,
the settings expected for the NMake Configuration Properties of this
project are:</small></p>
<ul style="font-family: verdana;">
  <li><small>Build Command Line: ddkbuild -W2K free .</small></li>
  <li><small>Rebuild Command Line: ddkbuild -W2K free . /a</small></li>
  <li><small>Output: WinPMC.sys</small></li>
</ul>
<p style="font-family: verdana;"><small>The same settings apply for the
debug version, with the substitution of the word 'checked' for the word
'free'.</small></p>
<small><span style="font-family: verdana;">To install the newly made
driver, run one of the supplied batch files found at </span><span
 style="font-weight: bold; font-family: verdana;">C:\papi\src\win2k\winpmc\[</span></small><small><span
 style="font-weight: bold; font-family: verdana;">instpmcfre.bat</span></small><small><span
 style="font-weight: bold; font-family: verdana;">, instpmcchk.bat</span></small><small><span
 style="font-weight: bold; font-family: verdana;">]</span><span
 style="font-family: verdana;">. These can be configured as external
tools in the Tools menu of Visual Studio.</span></small><br>
<p></p>
<h3><font face="Verdana"><font size="-1">TESTING</font></font></h3>
<font face="Verdana"><font size="-1">To test your WinPMC driver, run
the
WinPMCTest application found in the winpmc directory. Items in the Test
menu will exercise various aspects of the PMC driver. Actually, the
WinPMCTest application doesn't exist. I may have intended to write one
at some point, but never did. To really test the driver, build and run
the WinPAPI Shell application and exercise the test functions in the
Diagnostics panel.</font></font>
<h3><font face="Verdana"><font size="-1">RESOURCES</font></font></h3>
<font face="Verdana"><font size="-1">For the latest release of the
Windows
NT device driver kit, see <a href="http://www.microsoft.com/ddk/">http://www.microsoft.com/ddk/</a>.<br>
For the latest release of the ddkbuild batch file, see </font></font> <a
 href="http://www.hollistech.com/Resources/ddkbuild/ddkbuild.htm">http://www.hollistech.com/Resources/ddkbuild/ddkbuild.htm</a>.<br>
Other components mentioned above are part of the PAPI distribution.<br>
&nbsp;<br>
<h3><font face="Verdana"><font size="-1">CODE TOUR</font></font></h3>
<h4>
<font face="Verdana"><font size="-1">File Manifest</font></font></h4>
<pre><u>Directory&nbsp;&nbsp; File&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Description<br><br></u>winpmc&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WinPMC.html&nbsp;&nbsp;&nbsp;&nbsp; Build documentation for this driver (this file).<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WinPMC.dsp,dsw&nbsp; Project and Workspace files for MS Visual C.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pmclib.c&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Source file for Driver interface library.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pmclib.h&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Header file for Driver interface library.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; instpmc.bat&nbsp;&nbsp;&nbsp;&nbsp; batch file to install and run the driver.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bldpmc.bat&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; batch file to build and run the driver.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ntaddsvc.exe&nbsp;&nbsp;&nbsp; driver installer called by instpmc.bat.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dirs&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Tells the build environment where to find Sources.<br>          &nbsp; Sources&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Generic file list for building the driver.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Makefile&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Used by the build environment. DON'T TOUCH.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pmc_x86.c&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Source file for PMC specific functionality.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pmc_x86.h&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Source file for PMC specific functionality.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WinPMC.c&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Source file for Windows Driver generic functionality.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; WinPMC.h&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Include file for Windows Driver generic functionality.</pre>
<center><font face="Verdana"><font size="-1"><a href="#top">Top of page</a></font></font></center>
<p><br>
<table border="0" cellspacing="0" width="624">
  <tbody>
    <tr>
      <td valign="CENTER" height="2" bgcolor="#00ffff"><br>
      </td>
    </tr>
  </tbody>
</table>
</p>
<p><font face="MS Sans Serif"><font size="-2">&copy; 2001 Innovative
Computing
Laboratory, University of Tennessee</font></font>
</p>
</body>
</html>
